<?php
namespace app\home\controller;

use app\home\common\Common;
use app\home\common\Page;
use app\home\common\Pagetwo;
use app\home\service\Smstmp;
use app\infrastructure\uri\Request;
use app\infrastructure\uri\Uri;
use think\Db;

/**
 * Created by PhpStorm.
 * User: YD
 * Date: 2017/4/26
 * Time: 16:52
 */
class Check extends Common
{
    private $client;
    public  function  __construct(){
        parent::__construct();
        $this->client=new Request();
    }
    /**
     * @return \think\response\View
     * 待审核列表
     */
    public function checkingList()
    {
        $map['lk.check_status']="pending";
        $map['lk.usercer_reject_count']=0;
        $where=[];
        if(session('role') == 'admin'){
            $map['u.userPhone'][]=["exp",'REGEXP "^[0-9][0-9]{8}[0-9]$"'];
            $map['u.userPhone'][]=["NOT LIKE",'1111111%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
      $this->assign('loanMore',$loanMore);
        if(isset($_GET['userPhone']) && !empty($_GET['userPhone'])){
            $map['lk.user_phone_num']=$_GET['userPhone'];
        }
        if(isset($_GET['sms_status']) && $_GET['sms_status'] !=11){
            $map['u.admin_sms_status']=$_GET['sms_status'];
        }

        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
          if($v['count(*)'] >=2){
              $newMoreTwo[]=$v['user_phone_num'];
          }
        }
        $this->assign('moreTwo',$newMoreTwo);
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count")
            ->paginate(15,false,['query' => request()->param()]);
        $page = $data->render();

        //统计总数量
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newData=[];
        foreach($data as $k=>$v){
            $newData[]=[
                "id"=>$v['id'],
                "user_id"=>$v['user_id'],
                "user_phone_num"=>$v['user_phone_num'],
                "check_user_id"=>$v['check_user_id'],
                "user_loan_id"=>$v['user_loan_id'],
                "check_status"=>$v['check_status'],
                "check_process"=>$v['check_process'],
                "comment"=>$v['comment'],
                "product_id"=>$v['product_id'],
                "create_time"=>$this->gmtToIndiaTimeByMysql($v['create_time']),
                "update_time"=>$this->gmtToIndiaTimeByMysql($v['update_time']),
                "admin_sms_status"=>$v['admin_sms_status']
            ];
        }
        if(isset($_GET['extend']) && $_GET['extend'] == 1){
            $column_name=[
                [
                    'ID',
                    'user_id',
                    'user_phone_num',
                    'check_user_id',
                    'user_loan_id',
                    'check_status',
                    'check_process',
                    'comment',
                    'product_id',
                    'create_time',
                    'update_time',
                    'admin_sms_status'
                ]
            ];
            $data = array_merge($column_name,$newData);
            $this->extendToExcel($data);
        }

        $this->assign('page',$page);
        $this->assign('data',$newData);
        $this->assign('totalCount',$totalCount);
        return view();
    }
    /**
     *  驳回待审核列表
     */
    public function checkingPendList(){
        $tmpUrl=Uri::HOST.Uri::SELECTSMSTMP.'?is_valid=1&plantForm=1';
        $smsTmp=$this->client->getArrayData($tmpUrl);
        if($smsTmp['code'] != 0){
            $smsTmp=[];
        }else{
            $smsTmp=$smsTmp['data'];
        }
        $this->assign('smsTmp',$smsTmp);
        $appSmsTmp=(new Smstmp())->getAppSmsTmp(2);
        $this->assign('appSmsTmp',$appSmsTmp);
        //语音推送模板
        $smsVoiceTmp=(new Smstmp())->getAppSmsTmp(3);
        $this->assign('smsVoiceTmp',$smsVoiceTmp);


        $map['lk.check_status']="pending";
        $map['lk.usercer_reject_count']=['GT',0];
        $where=[];
        if(session('role') == 'admin'){
            $map['u.userPhone'][]=["exp",'REGEXP "^[0-9][0-9]{8}[0-9]$"'];
            $map['u.userPhone'][]=["NOT LIKE",'1111111%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
        }
        if(isset($_GET['userPhone']) && !empty($_GET['userPhone'])){
            $map['lk.user_phone_num']=$_GET['userPhone'];
        }

        if(isset($_GET['sms_status']) && $_GET['sms_status'] !=11){
            $map['u.admin_sms_status']=$_GET['sms_status'];
        }

        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $this->assign('moreTwo',$newMoreTwo);
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count")
            ->paginate(15,false,['query' => request()->param()]);
        $page = $data->render();

        //统计总数量
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newData=[];
        foreach($data as $k=>$v){
            $newData[]=[
                "id"=>$v['id'],
                "user_id"=>$v['user_id'],
                "user_phone_num"=>$v['user_phone_num'],
                "check_user_id"=>$v['check_user_id'],
                "user_loan_id"=>$v['user_loan_id'],
                "check_status"=>$v['check_status'],
                "check_process"=>$v['check_process'],
                "comment"=>$v['comment'],
                "product_id"=>$v['product_id'],
                "create_time"=>$this->gmtToIndiaTimeByMysql($v['create_time']),
                "update_time"=>$this->gmtToIndiaTimeByMysql($v['update_time']),
                "admin_sms_status"=>$v['admin_sms_status']
            ];
        }
        if(isset($_GET['extend']) && $_GET['extend'] == 1){
            $column_name=[
                [
                    'ID',
                    'user_id',
                    'user_phone_num',
                    'check_user_id',
                    'user_loan_id',
                    'check_status',
                    'check_process',
                    'comment',
                    'product_id',
                    'create_time',
                    'update_time',
                    'admin_sms_status'
                ]
            ];
            $data = array_merge($column_name,$newData);
            $this->extendToExcel($data);
        }

        $this->assign('page',$page);
        $this->assign('data',$newData);
        $this->assign('totalCount',$totalCount);

        //获取该业的电话号码
        $phone=[];
        foreach($data as $k=>$v){
           $phone[]=[
               "userPhone"=>$v['user_phone_num'],
               "userID"=>$v['user_id']
           ];
        }
        $phone=json_encode($phone);
        $this->assign('phone',$phone);
        return view();
    }
    /**
     * @return \think\response\View
     * 审核通过列表
     */
    public function checkedList()
    {
        $where=[];
        $map['lk.check_status']="resolve";
        if(session('role') == 'admin'){
            $map['u.userPhone'][]=["exp",'REGEXP "^[0-9][0-9]{8}[0-9]$"'];
            $map['u.userPhone'][]=["NOT LIKE",'1111111%'];
        }else if(session('role') == 'testing'){
            $where['u.userPhone'][]=["exp",'REGEXP "^1[0-9]{10}"'];
            $where['u.userPhone'][]=["LIKE",'1111111%'];
        }
        if(isset($_GET['userPhone']) && !empty($_GET['userPhone'])){
            $map['lk.user_phone_num']=$_GET['userPhone'];
        }
        if(isset($_GET['loanRepayPeriod']) && !empty($_GET['loanRepayPeriod'])){
            $map['ul.loanRepayPeriod']=$_GET['loanRepayPeriod'];
        }
        if(isset($_GET['actualAmount']) && !empty($_GET['actualAmount'])){
            $map['ul.actualAmount']=$_GET['actualAmount'];
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("userloans ul",'lk.user_loan_id = ul.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,ul.actualAmount,ul.loanRepayPeriod")
            ->order("lk.update_time desc")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("userloans ul",'lk.user_loan_id = ul.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->count();
        $newData=[];
        foreach($data as $k=>$v){
            $newData[]=[
                "id"=>$v['id'],
                "user_id"=>$v['user_id'],
                "user_phone_num"=>$v['user_phone_num'],
                "check_user_id"=>$v['check_user_id'],
                "user_loan_id"=>$v['user_loan_id'],
                "check_status"=>$v['check_status'],
                "check_process"=>$v['check_process'],
                "comment"=>$v['comment'],
                "actualAmount"=>$v['actualAmount'],
                "loanRepayPeriod"=>$v['loanRepayPeriod'],
                "create_time"=>$this->gmtToIndiaTimeByMysql($v['create_time']),
                "update_time"=>$this->gmtToIndiaTimeByMysql($v['update_time']),
                "admin_sms_status"=>$v['admin_sms_status']
            ];
        }

        $page = $data->render();
        $this->assign('page',$page);
        $this->assign('data',$newData);
        $this->assign('totalCount',$totalCount);
        return view();
    }
    /**
     * @return \think\response\Views
     * 审核不通过列表
     */
    public function checkedNoList()
    {
        $where=[];
        $map['lk.check_status']="reject";
        if(session('role') == 'admin'){
            $map['u.userPhone'][]=["exp",'REGEXP "^[0-9][0-9]{8}[0-9]$"'];
            $map['u.userPhone'][]=["NOT LIKE",'1111111%'];
        }else if(session('role') == 'testing'){
            $where['u.userPhone'][]=["exp",'REGEXP "^1[0-9]{10}"'];
            $where['u.userPhone'][]=["LIKE",'1111111%'];
        }
        if(isset($_GET['userPhone']) && !empty($_GET['userPhone'])){
            $map['lk.user_phone_num']=$_GET['userPhone'];
        }
        if(isset($_GET['loanRepayPeriod']) && !empty($_GET['loanRepayPeriod'])){
            $map['ul.loanRepayPeriod']=$_GET['loanRepayPeriod'];
        }
        if(isset($_GET['actualAmount']) && !empty($_GET['actualAmount'])){
            $map['ul.actualAmount']=$_GET['actualAmount'];
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("userloans ul",'lk.user_loan_id = ul.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,ul.actualAmount,ul.loanRepayPeriod")
            ->order("lk.update_time desc")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("userloans ul",'lk.user_loan_id = ul.id','LEFT')
            ->whereOr($where)
            ->where($map)
            ->count();
        $newData=[];
        foreach($data as $k=>$v){
            $newData[]=[
                "id"=>$v['id'],
                "user_id"=>$v['user_id'],
                "user_phone_num"=>$v['user_phone_num'],
                "check_user_id"=>$v['check_user_id'],
                "user_loan_id"=>$v['user_loan_id'],
                "check_status"=>$v['check_status'],
                "check_process"=>$v['check_process'],
                "comment"=>$v['comment'],
                "actualAmount"=>$v['actualAmount'],
                "loanRepayPeriod"=>$v['loanRepayPeriod'],
                "create_time"=>$this->gmtToIndiaTimeByMysql($v['create_time']),
                "update_time"=>$this->gmtToIndiaTimeByMysql($v['update_time']),
                "admin_sms_status"=>$v['admin_sms_status']
            ];
        }
        $page = $data->render();
        $this->assign('page',$page);
        $this->assign('data',$newData);
        $this->assign('totalCount',$totalCount);
        return view();
    }
    /**
     * @return \think\response\View
     * 审核详情
     */
    public function checkinfo(){
        $id=$_GET['uid'];
        //查询该审核信息
        $client=new Request();
        $checkUrl=Uri::HOST.Uri::SELECTCHECK."?id=".$id;
        $checkInfo=$client->getArrayData($checkUrl);
        //查询借款信息
        $userLoanUrl=Uri::HOST.Uri::SELECTUSERLOAN."?id=".$checkInfo['data'][0]['user_loan_id'];
        $userLoanInfo=$client->getArrayData($userLoanUrl);
        //查询用户信息
        $userUrl=Uri::HOST.Uri::USERLIST."?id=".$checkInfo['data'][0]['user_id'];
        $userInfo=$client->getArrayData($userUrl);
        //查询产品相关消息
        $productUrl= Uri::HOST.Uri::PRODUCTLIST."?id=".$checkInfo['data'][0]['product_id'];
        $productInfo=$client->getArrayData($productUrl);
        //查询公司认证信息
        $companyCerUrl=Uri::HOST.Uri::USERCOMPANYCERITYS."?userID=".$checkInfo['data'][0]['user_id'];
        $companyCerInfo=$client->getArrayData($companyCerUrl);
        //查询个人认证信息
        $userCerUrl=Uri::HOST.Uri::USERCERITYS."?phoneNumber=".$checkInfo['data'][0]['user_phone_num'];
        $userCerInfo=$client->getArrayData($userCerUrl);

        //查询aadhaar认证信息
        $aadhaarCerUrl=Uri::HOST.Uri::FINDAADHAARS."?phoneNumber=".$checkInfo['data'][0]['user_phone_num'];
        $aadhaarCerInfo=$client->getArrayData($aadhaarCerUrl);

        //个人信息
        $personInfoUrl=Uri::HOST.Uri::SELECTPERSONINFO."?user_id=".$checkInfo['data'][0]['user_id'];
        $personInfo=$this->client->getArrayData($personInfoUrl);

        //查询用户银行卡信息
//        $accountInfoUrl=Uri::HOST.Uri::SELECTUSERBANK.$checkInfo['data'][0]['user_id'];
//        $userAccount=$this->client->getArrayData($accountInfoUrl);
        $userAccount=Db::table("useraccount")
            ->where("user_id",$checkInfo['data'][0]['user_id'])
            ->where("is_valid",1)
            ->order("update_time","DESC")
            ->find();

        //历史无效银行卡
//        $useraccountListUrl=Uri::HOST.Uri::SELECTACCOUNT."?user_id=".$checkInfo['data'][0]['user_id'];
//        $useraccountList=$this->client->getArrayData($useraccountListUrl);

        //将这些银行卡至为无效
        Db::table("useraccount")
            ->where("user_id",$checkInfo['data'][0]['user_id'])
            ->where('id',"NEQ",$userAccount['id'])
            ->update(["is_valid"=>0]);

        $useraccountList=Db::table("useraccount")
            ->where("user_id",$checkInfo['data'][0]['user_id'])
            ->where("is_valid",0)
            ->select();

        //查找人脸识别信息
        $url=Uri::HOST.Uri::SELECTUSERFACE."?user_id=".$checkInfo['data'][0]['user_id'];
        $userFace=$this->client->getArrayData($url);

        //查询criff积分
        $like=$checkInfo['data'][0]['user_phone_num']."p%";
        $criff=Db::table('user_criff')
            ->where("cutRefNum","LIKE",$like)
            ->order("create_time",'DESC')
            ->limit(1)
            ->find();
        if(empty($criff)){
            $criff=[];
        }
        $this->assign('criff',$criff);
//        dd($companyCerInfo['data']);
//        dd($userCerInfo);
//        dd($aadhaarCerInfo);
//        dd($userLoanInfo);
        if(empty($companyCerInfo['data'])){
            $companyCerInfo=[];
        }else{
            $companyCerInfo=$companyCerInfo['data'][0];
        }
        if(empty($userCerInfo['data'])){
            $userCerInfo=[];
        }else{
            $userCerInfo=$userCerInfo['data'][0];
        }
        if(empty($aadhaarCerInfo['data'])){
            $aadhaarCerInfo=[];
        }else{
            $aadhaarCerInfo=$aadhaarCerInfo['data'][0];
        }

        if(empty($personInfo['data'])){
            $personInfo=[];
        }else{
            $personInfo=$personInfo['data'][0];
        }

        if(empty($userAccount)){
            $userAccount=[];
        }else{
            $userAccount=$userAccount;
        }

        if(empty($useraccountList)){
            $useraccountList=[];
        }else{
            $useraccountList=$useraccountList;
        }

        if(empty($userFace['data'])){
            $userFace=[];
        }else{
            $userFace=$userFace['data'][0];
            $userFaceInfo=$userFace;
            $userFace=json_decode($userFace['photo']);

        }
//        dd($userFace);
        $this->assign('userFaceInfo',$userFaceInfo);
        $this->assign('userFace',$userFace);
        $this->assign('useraccountList',$useraccountList);
        $this->assign('userAccount',$userAccount);
        $this->assign('personInfo',$personInfo);
        $this->assign('companyCerInfo',$companyCerInfo);
        $this->assign('userCerInfo',$userCerInfo);
        $this->assign('aadhaarCerInfo',$aadhaarCerInfo);


        $this->assign('loanCheck',$checkInfo['data'][0]);
        $this->assign('userLoan',$userLoanInfo['data'][0]);
        $this->assign('user',$userInfo['data'][0]);
        $this->assign('product',$productInfo['data'][0]);
//        dd($checkInfo);
        return view();
    }
    /**
     * 审核是否通过
     */
    public function checkPass(){
        if(\think\Request::instance()->isAjax()){
            $loanCheckId=$_GET['id'];
            $type=$_GET['type'];
            $client=new Request();
            $updateData=[
                'comment'=>$_GET['content']
            ];
            if($type == 0){
                //不通过
                $checkUrl=Uri::HOST.Uri::CHECKNOPASS.$loanCheckId;
            }else if($type == 1){
                //通过
                $checkUrl=Uri::HOST.Uri::CHECKPASS.$loanCheckId;
            }
            $res=$client->getArrayData($checkUrl,$updateData,3);
            return $res;
        }
    }
    /**
     * 获取cibil评分
     */
    public function getCibil(){
       $user_id=$_POST['uid'];
       $user_loan_id=$_POST['user_loan_id'];
        $checkId=$_POST['checkId'];

        $userInfoUrl=Uri::HOST.Uri::USERCERITYS."?phoneNumber=".$user_id;
        $userInfo=$this->client->getArrayData($userInfoUrl);
//        dd($userInfo);
        $userInfo=$userInfo['data'][0];

        $userLoanInfoUrl=Uri::HOST.Uri::SELECTUSERLOAN."?id=".$user_loan_id;
        $userLoanInfo=$this->client->getArrayData($userLoanInfoUrl);
        $userLoanInfo=$userLoanInfo['data'][0];
        $period=ceil($userLoanInfo['loanRepayPeriod']/30);
//        dd($userLoanInfo);
        $url=Uri::HOST.Uri::GETUSERCIBIL;
        $data=[
            "amount"=>"{$userLoanInfo['actualAmount']}",
            "period"=>"{$period}",
            "loan_check_id"=>$checkId,
            "firstName"=>$userInfo['firstname'],
            "middlename"=>$userInfo['middlename'],
            "lastName"=>$userInfo['lastname'],
            "birth"=>$userInfo['birthDay'],
            "gender"=>$userInfo['genderinfo'],
            "phoneNum"=>"{$userInfo['phoneNumber']}",
            "panNum"=>$userInfo['panID'],
            "aadhaarNum"=>$userInfo['aadhaar_num'],
            "address"=>[
                [
                    "AddressLine1"=> $userInfo['currentAddress'],
                    "AddressLine2"=>$userInfo['currentAddress'],
                    "AddressLine3"=> $userInfo['currentAddress'],
                    "AddressType"=>"02",
                    "City"=>$userInfo['currentCity'],
                    "PinCode"=> $userInfo['currentPinCode'],
                    "ResidenceType"=> "01",
                    "StateCode"=>$userInfo['currentState']
                ],
                [
                    "AddressLine1"=>$userInfo['permanentaAddress'],
                    "AddressLine2"=> $userInfo['permanentaAddress'],
                    "AddressLine3"=> $userInfo['permanentaAddress'],
                    "AddressType"=>"01",
                    "City"=>$userInfo['permanentCity'],
                    "PinCode"=> $userInfo['permanentaPinCode'],
                    "ResidenceType"=> "01",
                    "StateCode"=>$userInfo['permanentState']
                ]
            ],
        ];
//        dd($data);die;
        $res=$this->client->getArrayData($url,$data,3);
       return $res;
    }
    /**
     * 获取getCriff评分
     */
    public function getCriff(){
       $user_id=$_POST['uuid'];
       $user_phone=$_POST['uid'];
       $url=Uri::GETUSERCRIFF.$user_id.'/'.$user_phone;
        $aa=$this->client->getArrayData($url);
        return ["code"=>0,'msg'=>'The results will be updated in a few minutes.please wait and Refresh the page!','data'=>'The results will be updated in a few minutes.please wait and Refresh the page!'];
    }
    /**
     * 转换state
     */
    public function stateToCode($stateName){

     }
    /**
     * 修改银行的信息
     */
    public function updateBank(){
        $id=$_POST['uid'];
       $url=Uri::HOST.Uri::SELECTACCOUNT.'/'.$id;
        $data=[
            'is_valid'=>0
        ];
        return $this->client->getArrayData($url,$data,4);
    }

    /**
     *  低信用评分列表
     */
    public function lowCreditScoreList(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type'][]=['LT',650];
        $where['us.type'][]=['GT',0];
//        $where['us.score']=0;
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

    /**
     *  低信用评分列表  低信用Crif分（小于650分）并且SMS≤30条
     */
    public function lowCreditScoreList1(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type'][]=['LT',650];
        $where['us.type'][]=['GT',0];
        $where['us.smsTotalCount']=['ELT',30];
//        $where['us.score']=0;
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

    /**
     *  低信用评分列表 低信用Crif分（小于650分）并且SMS≥31条
     */
    public function lowCreditScoreList2(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type'][]=['LT',650];
        $where['us.type'][]=['GT',0];
        $where['us.smsTotalCount']=['EGT',31];
//        $where['us.score']=0;
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }
    /**
     * 年龄大于1979
     */
    public function ageToLarge(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=-1;
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->select();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }


    /**
     * 信用评分高用户
     */
    public function highScore(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=['EGT',650];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");

        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.smsCerResCount,us.id scoreId,us.smsTotalCount")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();

        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

    /**
     * 信用评分高用户，高信用Crif分（大于等于650分）并且SMS≤10条
     */
    public function highScore1(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=['EGT',650];
        $where['us.smsTotalCount']=['ELT',10];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");

        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.smsCerResCount,us.id scoreId,us.smsTotalCount")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();

        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

    /**
     * 信用评分高用户，高信用Crif分（大于等于650分）并且SMS在11-30条之内
     */
    public function highScore2(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=['EGT',650];
        $where['us.smsTotalCount']=['BETWEEN',[11,30]];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");

        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.smsCerResCount,us.id scoreId,us.smsTotalCount")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();

        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

    /**
     * 信用评分高用户，高信用Crif分（大于等于650分）并且SMS≥31条
     */
    public function highScore3(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=['EGT',650];
        $where['us.smsTotalCount']=['EGT',31];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");

        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.smsCerResCount,us.id scoreId,us.smsTotalCount")
            ->paginate(15);
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();

        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

    /*
     * 没有crif分列表获得criff为null
     */
    public function noCrifList(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=[['=',0],["=",null],'or'];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
//        dd(Db::table("loancheck")->getLastSql());die;
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

/*
     * 没有crif分列表获得criff为null 无CRIF 1
     */
    public function noCrifList1(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=[['=',0],["=",null],'or'];
        $where['us.smsTotalCount']=['ELT',10];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
//        dd(Db::table("loancheck")->getLastSql());die;
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }
/*
     * 没有crif分列表获得criff为null
     */
    public function noCrifList2(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=[['=',0],["=",null],'or'];
        $where['us.smsTotalCount']=['BETWEEN',[11,30]];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
//        dd(Db::table("loancheck")->getLastSql());die;
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }
/*
     * 没有crif分列表获得criff为null
     */
    public function noCrifList3(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        $where['us.crif']=0;
        $where['us.type']=[['=',0],["=",null],'or'];
        $where['us.smsTotalCount']=['EGT',31];
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
//        dd(Db::table("loancheck")->getLastSql());die;
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$data);
        return view();
    }

    /**
     * 续借待审核列表
     */
    public function loanMore(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        $where['lk.user_phone_num']=["in",$loanMore];
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
        $newData=[];
        foreach($data as $k=>$v){
          $repayLabel=Db::table("admin_user_repay_label")
              ->where("user_id",$v['user_id'])
              ->field("label")
              ->select();
            $newData[]=$v;
                $newData[$k]['repayLabel']=$repayLabel;
        }
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$newData);
        return view();
    }

    /**
     * 续借待审核列表  无坏账续借
     */
    public function loanMore1(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
            //查找有还账的用户
            $badcuser=Db::table("admin_user_repay_label")
                ->where("user_phone","NOT LIKE","1%")
                ->where("label","C")
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
            //查找有还账的用户
            $badcuser=Db::table("admin_user_repay_label")
                ->where("user_phone","LIKE","1%")
                ->where("label","C")
                ->distinct(true)
                ->column("user_phone");
        }
        $where['lk.user_phone_num'][]=["in",$loanMore];
        $where['lk.user_phone_num'][]=["not in",$badcuser];
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
        $newData=[];
        foreach($data as $k=>$v){
          $repayLabel=Db::table("admin_user_repay_label")
              ->where("user_id",$v['user_id'])
              ->field("label")
              ->select();
            $newData[]=$v;
                $newData[$k]['repayLabel']=$repayLabel;
        }
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$newData);
        return view();
    }

    /**
     * 续借待审核列表  有坏账续借
     */
    public function loanMore2(){
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        if(session('role') == 'admin'){
            $where['u.userPhone']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
            //查找有还账的用户
            $badcuser=Db::table("admin_user_repay_label")
                ->where("user_phone","NOT LIKE","1%")
                ->where("label","C")
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['u.userPhone']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();

            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
            //查找有还账的用户
            $badcuser=Db::table("admin_user_repay_label")
                ->where("user_phone","LIKE","1%")
                ->where("label","C")
                ->distinct(true)
                ->column("user_phone");
        }
        $where['lk.user_phone_num'][]=["in",$loanMore];
        $where['lk.user_phone_num'][]=["in",$badcuser];
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count,us.age,us.crif,us.type,us.score,us.smsCerRes,us.id scoreId,us.smsTotalCount,us.smsCerResCount")
            ->paginate(15);
        $newData=[];
        foreach($data as $k=>$v){
          $repayLabel=Db::table("admin_user_repay_label")
              ->where("user_id",$v['user_id'])
              ->field("label")
              ->select();
            $newData[]=$v;
                $newData[$k]['repayLabel']=$repayLabel;
        }
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->join("user_cerdit_score us","lk.user_id = us.user_id","LEFT")
            ->where($where)
            ->group("lk.id")
            ->order("lk.update_time desc")
            ->count();
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $page = $data->render();
        $this->assign("page",$page);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign("data",$newData);
        return view();
    }

    /**
     *  无分类待审核列表
     */
    public function  noCerditList(){
        $where=[];
        $where['lk.check_status']="pending";
        $where['lk.usercer_reject_count']=0;
        if(session('role') == 'admin'){
            $where['lk.user_phone_num']=["NOT LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","NOT LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","NOT LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        else if(session('role') == 'testing'){
            $where['lk.user_phone_num']=["LIKE",'1%'];
            //查找所有数据检测重复数据
            $moreTwo=Db::table("loancheck")
                ->where("check_status","pending")
                ->where("user_phone_num","LIKE","1%")
                ->field("user_phone_num,count(*)")
                ->group("user_phone_num")
                ->select();
            //查询续借用户
            $loanMore=Db::table("userrepay")
                ->where("user_phone","LIKE","1%")
                ->where("commit_status",1)
                ->where("repay_status",1)
                ->distinct(true)
                ->column("user_phone");
        }
        //查找所有的拥有flashCash评分的用户
        $flashCashCerditUser=Db::table("user_cerdit_score")
            ->distinct(true)
            ->column("user_id");
        $newMoreTwo=[];
        foreach($moreTwo as $k=>$v){
            if($v['count(*)'] >=2){
                $newMoreTwo[]=$v['user_phone_num'];
            }
        }
        $where['lk.user_id']=['not in',$flashCashCerditUser];
        $data=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->where($where)
            ->order("lk.update_time desc")
            ->field("lk.id id,lk.user_id user_id,lk.user_phone_num user_phone_num,lk.check_user_id check_user_id,lk.user_loan_id user_loan_id,lk.check_status check_status,lk.check_process check_process,lk.comment comment,lk.product_id product_id,lk.create_time create_time,lk.update_time update_time,u.admin_sms_status admin_sms_status,lk.usercer_reject_count")
            ->paginate(15);
        $page = $data->render();
        $totalCount=Db::table("loancheck")->alias('lk')
            ->join("user u",'lk.user_id = u.id','LEFT')
            ->where($where)
            ->count();
        $this->assign("data",$data);
        $this->assign("totalCount",$totalCount);
        $this->assign("moreTwo",$newMoreTwo);
        $this->assign("loanMore",$loanMore);
        $this->assign('page',$page);
        return view();
    }

    /**
     * 查询高危短信
     */
    public function viewHighRiskSms(){
        $id=$_POST['id'];
        $url=Uri::HOST.Uri::FINDHIGHRISKSMS."?id=".$id;
        $data=$this->client->getArrayData($url);
        return $data;

    }
}